function [time, P] = Project_Perm_n(G)

[N, d] = size(G);
n = N/d;

time_start = tic;
cvx_begin
    variable P(N,d) nonnegative
    maximize( trace(P'*G) )
    subject to 
        for i = 1:n
            sum( P((i-1)*d+1: i*d, :) ) == ones(1,d);
        end
        sum(P') == ones(1,N);
cvx_end

time = toc(time_start);